<div class="content_wrapper">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <aside>
                    <header><i class="fa fa-fw fa-file"></i>商品属性列表</header>
                    <section>
                        <div class="container-fluid">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="btn-group" style="margin-bottom:20px;">
                                        <button class="btn btn-default J_ajax_content_modal" data-href="./attribute/add.html">添加</button>
                                    </div>

                                    <div class="table-responsive">
                                        <table id="attribute_table" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                                            <thead>
                                            <tr>
                                                <th><input class="all_item_check" type="checkbox" value="" /></th>
                                                <th>id</th>
                                                <th>属性名称</th>
                                                <th>显示顺序</th>
                                                <th>状态</th>
                                                <th>商品分类</th>
                                            </tr>
                                            </thead>
                                            <tbody>

                                            </tbody>
                                        </table>
                                    </div>
                                    <nav id="pagination-hsx">

                                    </nav>
                                </div>
                            </div>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>


</div>

<script>
    $(document).ready(function () {
        var page;
        var lists;
        getAttributeData(1);
    });

    function getAttributeData(pageIndex) {
        $.ajax({
            type: 'post',
            url: common_conf.requestUrl+'attribute/list',
            contentType : 'application/json;charset=UTF-8',
            cache: false,
            data: '{"pageIndex":'+pageIndex+'}',
            dataType: 'json',
            beforeSend: function () {
            },
            success: function (returnData) {
                if(forceLogin(returnData)) return;
                var obj=returnData;
                if(obj.state=="success"){
                    var values=Array();
                    $.each(obj.list,function(index,attribute){
                        val=Array();
                        val[0]=attribute.id;
                        val[1]=attribute.name;
                        val[2]=attribute.sort;
                        val[3]=attribute.state==1 ? "显示" : "不显示";
                        var storage="";
                        switch (attribute.storage){
                            case 0:
                                storage="冰鲜";
                                break;
                            case 1:
                                storage="冻品";
                                break;
                            case 2:
                                storage="远洋";
                                break;
                            case 3:
                                storage="已加工";
                                break;
                            case 4:
                                storage="养殖";
                                break;
                        }
                        val[4]=storage;
                        values.push(val);
                    });
                    initTable("#attribute_table",values,"./#attribute/edit.html");
                    page=obj.page;
                    lists=values;
                    paginate(page,"pagination-hsx");
                    clickBind(page,"getAttributeData");

                }else{
                    alert("获取失败");
                }
            },
            error: function () {
                alert("未找到模板");
            }
        });
    }



</script>